package com.cy.pj.common.advisor;

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;
@Component
public class LogAdvisor extends StaticMethodMatcherPointcutAdvisor {
    public LogAdvisor(){
        //在这里写自己的通知
        setAdvice(new LogAdvice());
    }

    @Override
    public boolean matches(Method method, Class<?> aClass) {
       try {
           Method targrtMethod = aClass.getMethod(method.getName(), method.getParameterTypes());
           return targrtMethod.getName().equals("sendMag");

       }catch (Exception e){
           return false;
       }
    }
}
